# -*- coding: utf-8 -*-
"""
@Time ： 2024/4/29 14:52
@Auth ： gc
"""
import akshare as ak
import pandas as pd
s_stock = ak.stock_sz_a_spot_em()
h_stock = ak.stock_sh_a_spot_em()

stock = pd.concat([s_stock, h_stock])
stock[(stock['市盈率-动态'] >0) & (stock['市盈率-动态'] <= 30)
      & (stock['市净率'] <= 3) & (stock['总市值'] <= 5000000000)
      & (~stock['名称'].str.contains('ST'))
         & (stock['代码'].str.startswith('60') | stock['代码'].str.startswith('30'))].to_csv('5yue_hq.csv', index=False, encoding='gbk')
# stock[(stock['市盈率-动态'] >0) & (stock['市盈率-动态'] <= 30)
#       & (stock['市净率'] <= 3) & (stock['总市值'] <= 5000000000)
#       & (~stock['名称'].str.contains('ST')) & (~stock['名称'].str.startswith('688'))
#       & (~stock['名称'].str.startswith('300'))
#       ].to_csv('5yue_hq.csv', index=False, encoding='gbk')